#include <cstdio>

int main( )
{
    int n, w[ 27 ], i, j, k;
    int c1[ 51 ], c2[ 51 ], sum;
    scanf("%d", &n);
    while ( n-- )
    {
        for ( i = 1; i <= 26; i++ )
            scanf("%d", &w[ i ]);
        for ( i = 0; i <= 50; i++ )
            c1[ i ] = c2[ i ] = 0;
        c1[ 0 ] = 1;
        for ( i = 1; i <= 26; i++ )
        {
            for ( j = 0; j <= 50; j++ )
                for ( k = 0; k * i + j <= 50 && k <= w[ i ]; k++ )
                    c2[ j + k * i ] += c1[ j ];
            for ( j = 0; j <= 50; j++ )
            {
                c1[ j ] = c2[ j ];
                c2[ j ] = 0;
            }
        }
        sum = 0;
        for ( i = 1; i <= 50; i++ )
            sum += c1[ i ];
        printf("%d\n", sum);
    }
    return 0;
}
